def lol(n):
    kd = 0
    for j in range(2,n):
        if n%j == 0:
            kd += 1
            break
    if kd == 0:
        return n
    else:
        return 0
    
print("Введите 3 слова через пробел:")
cifri = list(map(str,input().split()))
kot = ""
v=["zero","one","two","three","four","five","six","seven","eight","nine"]
for i in range(len(cifri)):
    for j in range(len(v)):
        if cifri[i] == v[j]:
            kot+=str(j)
ch=1488888888
if len(kot)!=3:
    print("Wrong input")
elif int(kot)== lol(int(kot)):
    print(kot)
else:
    kot = int(kot)
    for i in range(kot - 25, kot + 25):
        if (lol(int(i)) != 0) and (ch > abs(kot - i)):
            ro = i
            ch = abs(kot - i)
    print(ro)